package ch10_IO流与文件.转换流;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @author 挚爱之夕
 * @date 2021/8/27 - 08 - 27 - 14:52
 * @Description: ch10.转换流
 * @Version: 1.0
 */
public class FakeAI {
    public static void main(String[] args) {
        String[] old = {"吗","你","？","?","Can you"};
        String[] replace = {"","我","!","！","I can"};
        String line = null; //存放输入的行
        try(InputStreamReader r = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(r)){
            System.out.print("人：");
            while(!"exit".equalsIgnoreCase(line = br.readLine())){  //输入的行不是exit
                for (int i = 0; i < old.length; i++) {
                    line = line.replace(old[i],replace[i]);
                }
                System.out.println("机："+line+" ["+r.getEncoding()+"]");
                System.out.print("人：");
            }
        }catch (IOException e){
            e.printStackTrace();
        }
    }
}
